package org.starsource.forum.server.domain;

public class ForeignKey<T extends HasId> {
	private int id;
	private T object;
	
	public int getId() {
		return this.id;
	}
	
	public void setId(int id) {
		this.id = id;
		this.object = null;
	}
	
	public T getObject() {
		return this.object;
	}
	
	public void setObject(T object) {
		this.object = object;
		
		if (this.object == null) {
			this.id = 0;
			return;
		}
		
		this.id = this.object.getId();
	}
}
